package com.example.wanglong.myoneapplication.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;

import com.example.wanglong.myoneapplication.R;
import com.example.wanglong.myoneapplication.common.BaseActivity;
import com.example.wanglong.myoneapplication.reparentclass.ReToast;

/**
 * Created by wang.long on 2016/4/8.
 */
public class ListSort extends BaseActivity implements View.OnClickListener {


    private LinearLayout allpage;

    private ListView sortcontent;
    private static final String[] strs = new String[] {"综合排序", "销量 高 → 低", "评分 高 → 低", "价格 低 → 高", "价格 高 → 低","提前预约天数 短 → 长"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sort_dialog);

        allpage=(LinearLayout) findViewById(R.id.allpage);
        sortcontent=(ListView) findViewById(R.id.sortcontent);




        allpage.setOnClickListener(this);

        //初始化
        initData();

    }


    public void initData(){

        sortcontent.setAdapter(new ArrayAdapter<String>(this,R.layout.suppliers_list_item, strs));
        sortcontent.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String desc = strs[position];
                ReToast.showToast(desc, ListSort.this);
            }
        });
    }


    @Override
    public void onClick(View v){
        switch (v.getId()){
            case R.id.exidvisatypecancel:
                operate("1");
                break;
            case R.id.exidvisatypesave:
                operate("2");
                break;
            case R.id.allpage:
                operate("3");
                break;

        }
    }


    public void operate(String desc){

        switch (desc){
            case "1":
                ReToast.showToast(desc, ListSort.this);
                break;
            case "2":
                SharedPreferences pref=getSharedPreferences("data",MODE_PRIVATE);
                String data=pref.getString("visatype","");
                ReToast.showToast(data, ListSort.this);
                break;
            case "3":
                ReToast.showToast("点击遮罩", ListSort.this);
                break;
        }
        finish();
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    }


}
